<template>
  <div>
    <router-link to="/home/user/123">go_home/user</router-link> <br>
    <router-link to="/home/dir">go_home/dir</router-link><br>
    <router-link to="/jurisdiction">go_jurisdiction</router-link><br>
    <router-link to="/imgs">imgs</router-link><br>
    <el-button @click="logout">退出</el-button>


    <ul v-if="datalist.length > 0">
      <pre>
        {{datalist}}
      </pre>
    </ul>
  </div>
</template>
  
  <script>
export default {



  data() {
    return {
      timer: null,
      datalist: [],
    };
  },

  // asyncData 这个是在服务端执行的生命周期-----主要进行异步请求
  async asyncData({ $axios, store, error }) {
    let data = await $axios({
        url: "/api/ceshi",
        method: "get",
      });

    return {
      title:"home页",
      content:"home描述信息",
      datalist: data.data
    };
  },

  // 通常在这儿将数据同步到vuex
  fetch({ store }) {},

  
  head() {   // 单独定制 这一个页面的头信息
     let data= this.$seo(this.title,this.content,[])
     console.log(data)
     return data
    // return {
    //   meta: [
    //     {
    //       name: "这是主页",
    //       content: "迎请，疫情",
    //     },
    //   ],
    // };
  },

  mounted() {},

  methods: {
    sleep(num = 5000) {
      clearTimeout(this.timer);
      return new Promise((res) => {
        this.timer = setTimeout(() => {
          res();
        }, num);
      });
    },
  
    logout() {
      this.$cookies.remove("userdata");
      this.$store.commit("setuserdata", null);
      this.$message.success("退出成功");
      this.$router.replace("/user/login");
    },
  },
};
</script>
  
  <style scoped>
.container {
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

img {
  max-width: 100px;
}
</style>
  